import request from '@/utils/request'

// 查询用户权限列表
export function listPermission(query) {
  return request({
    url: '/video/permission/list',
    method: 'get',
    params: query
  })
}

// 查询用户权限详细
export function getPermission(permissionId) {
  return request({
    url: '/video/permission/' + permissionId,
    method: 'get'
  })
}

// 新增用户权限（手动授予）
export function addPermission(data) {
  return request({
    url: '/video/permission',
    method: 'post',
    data: data
  })
}

// 修改用户权限
export function updatePermission(data) {
  return request({
    url: '/video/permission',
    method: 'put',
    data: data
  })
}

// 删除用户权限
export function delPermission(permissionId) {
  return request({
    url: '/video/permission/' + permissionId,
    method: 'delete'
  })
}

// 延长权限有效期
export function extendPermission(permissionId, days) {
  return request({
    url: '/video/permission/extend/' + permissionId + '?days=' + days,
    method: 'put'
  })
}

// 批量延长权限
export function batchExtend(permissionIds, days) {
  return request({
    url: '/video/permission/batchExtend?days=' + days,
    method: 'put',
    data: permissionIds
  })
}

// 刷新过期状态
export function refreshStatus() {
  return request({
    url: '/video/permission/refresh',
    method: 'put'
  })
}

